<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.title.center_zhuyonghu"></spring:message></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
    <style type="text/css">
       
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>用户管理</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
             <li class="active"><a href="#">用户管理</a></li>
            <li class="active"><a href="#">用户管理</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <form id="form">
                    <div class="input">
                    <div class="textalign1">名称：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="name" name="name" placeholder="名称" maxlength="50" />
                    </div>
                    <div class="textalign1">账号：</div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="username" name="username" placeholder="账号" maxlength="25" />
                    </div>
                    <button type="button" class="btn btn-success btn-sm" onclick="search();">查 询</button>
                     <button id="addUserBtn" type="button" class="btn btn-success btn-sm" onclick="addUser();">新 增</button>
                </div>
               
              </form>  
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
			<label id="addNew" onclick="addUser();" class="btn btn-default btn-sm">新 增</label>
			<label id="addNew" onclick="deleteUser();" class="btn btn-default btn-sm">删 除</label>

		</div>
        <div  class="modal fade" id="dialog" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header bg-primary">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h5 class="modal-title"><spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.add"/></h5>
					</div>
					<div class="modal-body">
						<div class="form-group form-group-xs">
							<label for="userType" class="control-label"><spring:message code="message.lable.userType"></spring:message><spring:message code="message.yanZheng.maoHao"/></label>
							<select id="userType" class="form-control">
								<option value=""><spring:message code="message.select.option"/></option>
								<c:if test="${ userTypeList != null }">
									<c:forEach items="${ userTypeList }" var="userType">
										<option value="${userType.key}">${userType.value}</option>
									</c:forEach>
								</c:if>
							</select>
						</div>
						
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary btn-sm" onclick="ok();"><spring:message code="message.button.okSpacing"/></button>
						<button type="button" class="btn btn-danger btn-sm" id="close" data-dismiss="modal"><spring:message code="message.button.closeSpacing" /></button>
					</div>
				</div>
			</div>
		</div>
		
		<div class="modal fade" id="changePasswordDialog" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header bg-primary">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h5 class="modal-title"><spring:message code="message.lable.resetPWD"></spring:message></h5>
					</div>
					<div class="modal-body">
						<div class="form-group form-group-xs">
							<label for="password" class="control-label"><spring:message code="message.lable.newPWD"></spring:message><spring:message code="message.yanZheng.maoHao"/></label>
							<input class="form-control" type="password" id="password" maxlength="127" />
						</div>
						<div class="form-group form-group-xs">
							<label for="passwordRepeat" class="control-label"><spring:message code="message.lable.confirmPWD"></spring:message><spring:message code="message.yanZheng.maoHao"/></label>
							<input class="form-control" type="password" id="passwordRepeat" maxlength="127" />
						</div>
						   <div class="form-group form-group-xs">
					        <label for="newpassword" class="col-sm-2 text-right"><i class="fa fa-exclamation-circle fa-lg" style="color:#dd4b39;"></i>&nbsp;<span style="color:#dd4b39;font-weight:600"><spring:message code="message.lable.tiShi" /><spring:message code="message.yanZheng.maoHao"/></span></label>					        
						    <div class="col-sm-6.5 text-left" style="color:#dd4b39">
						         <spring:message code="message.lable.PWDhint" />
						    </div>
				         </div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary btn-sm reSetPsr" onclick="submitPassword();"><spring:message code="message.button.okSpacing"></spring:message></button>
						<button type="button" class="btn btn-danger btn-sm" id="closeChangePasswordDialog" data-dismiss="modal"><spring:message code="message.button.closeSpacing"></spring:message></button>
					</div>
				</div>
			</div>
		</div>
		
		<div class="modal fade" id="zxUserEdit" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header bg-primary">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h5 class="modal-title"><spring:message code="message.title.zhuyonghu"/><spring:message code="message.button.edit"/></h5>
					</div>
                 <form class="form-horizontal"  action="saveZUser.html" id="form2" method="post">
                 <input type="hidden" id="id" name="id" value="" />
					<div class="modal-body">
						<div class="form-group form-group-xs">
	                        <label for="username" class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.lable.userzhanghaoSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="username2" name="username" value="" placeholder="<spring:message code="message.lable.userzhanghaoSpacing"/>" type="text" readonly="readonly">
	                        </div>
	                        <label for="name" class="col-sm-3 text-right"><span class="required">*</span><spring:message code="message.lable.usernameSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="name2" name="name"  type="text" maxlength="50"placeholder=" <spring:message code="message.lable.usernameSpacing"/>">
	                        </div>
	                    </div>
	                    <div class="form-group form-group-xs">
	                        <label for="email" class="col-sm-2 text-right"><spring:message code="message.lable.useremailSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="email" name="email" value="" placeholder="<spring:message code="message.lable.useremailSpacing"/>" type="text" maxlength="25">
	                        </div>
	                        <label for="phone" class="col-sm-3 text-right"><spring:message code="message.lable.phoneSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="phone" name="phone" value="" placeholder="<spring:message code="message.lable.phoneSpacing"/>" type="text" maxlength="25">
	                        </div>
	                    </div>
	                    
	                    
	                    <div class="form-group form-group-xs">
	                        <label for="email" class="col-sm-2 text-right">到期日期：</label>
	                        <div class="col-sm-3 text-left">
	                        <input class="form-control" id="editacctExpired" name="acctExpired" type="text" data-provide="datepicker" placeholder="yyyy-MM-dd" 
											data-date-fmt="yyyy-MM-dd"/>
	                        </div>
	                        <label for="phone" class="col-sm-3 text-right">体重</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="editweight" name="weight" value="" placeholder="体重" type="text" maxlength="25">
	                        </div>
	                    </div>
	                    <div class="form-group form-group-xs">
	                        <label for="email" class="col-sm-2 text-right">身高：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="editbodyHeight" name="bodyHeight" value="" placeholder="身高" type="text" maxlength="25">
	                        </div>
	                        <label for="phone" class="col-sm-3 text-right">腰围：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="editwaist" name="waist" value="" placeholder="腰围" type="text" maxlength="25">
	                        </div>
	                    </div>
	                    
	                    
	                    
	                    <div class="form-group form-group-xs">
	                        <label for="remark" class="col-sm-2 text-right"><spring:message code="message.lable.remarkSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-9">
	                            <textarea class="form-control" id="remark" name="remark" rows="5" placeholder="<spring:message code="message.lable.remarkSpacing"/>" maxlength="500"></textarea>
	                        </div>
                   		</div>
					</div>
					</form>
					<div class="modal-footer">
						 <button type="button" class="btn btn-primary btn-sm" onclick="zxSaveUser();"><spring:message code="message.button.saveSpacing"/></button>
						<button type="button" class="btn btn-danger btn-sm" id="closeChangePasswordDialog" data-dismiss="modal"><spring:message code="message.button.closeSpacing"/></button>
					</div>
				</div>
			</div>
		</div>
		
		
		
		
		<div class="modal fade" id="zxUserAdd" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header bg-primary">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h5 class="modal-title">用户新增</h5>
					</div>
                 <form class="form-horizontal"  action="addZUser.html" id="addForm" method="post">
					<div class="modal-body">
						<div class="form-group form-group-xs">
	                        <label for="username" class="col-sm-2 text-right"><span class="required">*</span>账 号：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addusername" name="username" value="" placeholder="账号" type="text">
	                        </div>
	                        <label for="name" class="col-sm-3 text-right"><span class="required">*</span>用户名：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addname" name="name"  type="text" maxlength="50"placeholder="用户名">
	                        </div>
	                    </div>
	                    <div class="form-group form-group-xs">
	                        <label for="username" class="col-sm-2 text-right"><span class="required">*</span>密 码：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addpassword" name="password" value="" placeholder="密码" type="password" >
	                        </div>
	                        <label for="name" class="col-sm-3 text-right"><span class="required">*</span>确认密码：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addconfirmpassword" name="addconfirmpassword"  type="password" maxlength="50"placeholder="确认密码">
	                        </div>
	                    </div>
	                    <div class="form-group form-group-xs">
	                        <label for="email" class="col-sm-2 text-right"><spring:message code="message.lable.useremailSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addemail" name="email" value="" placeholder="<spring:message code="message.lable.useremailSpacing"/>" type="text" maxlength="25">
	                        </div>
	                        <label for="phone" class="col-sm-3 text-right"><spring:message code="message.lable.phoneSpacing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addphone" name="phone" value="" placeholder="<spring:message code="message.lable.phoneSpacing"/>" type="text" maxlength="25">
	                        </div>
	                    </div>
	                    
	                    
	                    
	                    
	                    <div class="form-group form-group-xs">
	                        <label for="email" class="col-sm-2 text-right">到期日期：</label>
	                        <div class="col-sm-3 text-left">
	                        <input class="form-control" id="addacctExpired" name="acctExpired" type="text" data-provide="datepicker" placeholder="yyyy-MM-dd" 
											data-date-fmt="yyyy-MM-dd"/>
	                        </div>
	                        <label for="phone" class="col-sm-3 text-right">体重</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addweight" name="weight" value="" placeholder="体重" type="text" maxlength="25">
	                        </div>
	                    </div>
	                    <div class="form-group form-group-xs">
	                        <label for="email" class="col-sm-2 text-right">身高：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addbodyHeight" name="bodyHeight" value="" placeholder="身高" type="text" maxlength="25">
	                        </div>
	                        <label for="phone" class="col-sm-3 text-right">腰围：</label>
	                        <div class="col-sm-3 text-left">
	                            <input class="form-control" id="addwaist" name="waist" value="" placeholder="腰围" type="text" maxlength="25">
	                        </div>
	                    </div>
	                    
	                    
	                    
	                    <div class="form-group form-group-xs">
	                        <label for="remark" class="col-sm-2 text-right">备注：</label>
	                        <div class="col-sm-9">
	                            <textarea class="form-control" id="addremark" name="remark" rows="5" placeholder="<spring:message code="message.lable.remarkSpacing"/>" maxlength="500"></textarea>
	                        </div>
                   		</div>
					</div>
					</form>
					<div class="modal-footer">
						 <button type="button" class="btn btn-primary btn-sm" onclick="addNewUser();"><spring:message code="message.button.saveSpacing"/></button>
						<button type="button" class="btn btn-danger btn-sm" id="closeChangePasswordDialog" data-dismiss="modal"><spring:message code="message.button.closeSpacing"/></button>
					</div>
				</div>
			</div>
		</div>
		
		
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
		 $(function(){
			  $("#name").focus();//加载页面光标在第一个查询框内
			 
			 $('.form-inline :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(0).focus();
		     $("form#form2 :input").change(function(){
	    		$("form#form2").data("changed",true);
	    	 })
			 
		 })
		 
		 function deleteUser(){
			 var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
			 if (rowIds.length < 1){
				 $.HN.message.alert("请选择要删除的用户！", "warn");
				 return;
			 }
		    	var list = [];
		    	for(var i = 0;i<rowIds.length;i++){
					list.push({"id":rowIds[i]});
				}
		    	$.HN.message.confirm("确定要删除用户？", '', '').on(function (e) {
		            if (e) {
				$.post("${pageContext.request.contextPath}/sysUser/deleteUser.html", {
					"array" : json.jsonToString(list)
				}, function(result) {
					if (result.success) {
						$.HN.message.alert("删除成功！", "success");
						$("#gridlist").trigger("reloadGrid");
					} else {
						$.HN.message.alert("删除失败！", "error");
					}
				}, "json");
		            }
				});
		 }
		 
		 function addNewUser(){
			 if ($("#addpassword").val() != $("#addconfirmpassword").val()){
				 $.HN.message.alert("密码不一致！", "warn");
				 return;
			 }
			 $.HN.message.confirm("确定要新增用户？", '', '').on(function (e) {
	              if (e) {
	           		$("#addForm").ajaxSubmit({
	        			dataType : "json",
	        			timeout: 10000,
	        			success : function(result, statusText) {
	        				if (result.success) {
	        					    $('#zxUserAdd').modal('hide');
	        					    search( $("#gridlist").getGridParam("page"));
	        					    top.$.HN.message.alert("<spring:message code='message.HN.alert.success'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "success");
	        				} else {
	        					top.$.HN.message.alert(result.msg || "", "<spring:message code='message.HN.alert.type'/>", "error");
	        				}
	        			}
	        		});
	    		}
	       	  });
		 }
		 
		 
    	var id = "";
       	//	保存用户信息
    	function zxSaveUser() {
    		if (!validate()) {
    			return;
    		}
       	  $.HN.message.confirm("<spring:message code='message.HN.alert.OkSaveYESorNO'/>", '', '').on(function (e) {
              if (e) {
           		$("#form2").ajaxSubmit({
        			dataType : "json",
        			timeout: 10000,
        			success : function(result, statusText) {
        				if (result.success) {
        					    $('#zxUserEdit').modal('hide');
        					    search( $("#gridlist").getGridParam("page"));
        					    top.$.HN.message.alert("<spring:message code='message.HN.alert.success'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "success");
        				} else {
        					top.$.HN.message.alert(result.msg || "", "<spring:message code='message.HN.alert.type'/>", "error");
        				}
        			}
        		});
    		}
       	  });
       	}
    	//	校验用户信息
    	function validate() {
    		/**
    		if(!$("form#form2").data("changed")){
				top.$.HN.message.alert("<spring:message code='message.lable.noModify'/>", "", "warn");
    			return false;  		
        	}
    		*/
    		
    		var name = $.trim($("#name2").val());
    		if (name == null || name == "") {
    			top.$.HN.message.alert("<spring:message code='message.lable.text'/><spring:message code='message.HN.alert.input'/><spring:message code='message.lable.username'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "warn");
    			$("#name2").focus();
    			return false;
    		}
    		
    		var email = $.trim($("#email").val());
    		if (email.replace(/(^s*)|(s*$)/g, "").length !=0) {
    			 var a =/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/;
    			if(!a.test(email)){
    				top.$.HN.message.alert("<spring:message code='message.lable.useremail'/><spring:message code='message.HN.alert.gsbzq'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "warn");
		        	$("#email").focus();
	    			return false;
		   		 }
    		}
    		var phone = $.trim($("#phone").val());
    		if (phone.replace(/(^s*)|(s*$)/g, "").length !=0) {
    			var b=/((15)\d{9})|((13)\d{9})|((18)\d{9})|(0[1-9]{2,3}\-?[1-9]{6,7})/i;  
    			if(!b.test(phone)){
    				top.$.HN.message.alert("<spring:message code='message.lable.phone'/><spring:message code='message.HN.alert.gsbzq'/>", "<spring:message code='message.HN.alert.type'/>", "warn");
    		        	$("#phone").focus();
    	    			return false;
    		    }
    		}
    		return true;
    	}
    	function selectUserType() {
    		$('#dialog').modal({
                keyboard: true
            });
    	}
    	
    	function ok() {
    		var userType = $("#userType").val();
    		if (userType != null && userType != "") {
    			document.location = "${ctx}/sysUser/zxUserSelected.html?userType=" + userType;
    		} else {
    			top.$.HN.message.alert("<spring:message code='message.select.option'/><spring:message code='message.lable.userType'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "warn");
    		}
    	}
    	
    	function batchChangeStatus(flag) {
    		var statusName = "<spring:message code='message.button.start' />";
    		var url = "${ctx}/sysUser/enable.html"
        	if (flag == 0){
        		statusName = "<spring:message code='message.button.stop' />";
        		 url = "${ctx}/sysUser/disable.html"
        	}
        	//获取选中的ID及对应的名字（参数:jqgridId,名字列名，状态列名，当前操作即列表中显示的值），返回infos[0]是ID串，infos[1]是名字串
        	var infos = batchSwitchStatus("gridlist","username","statusName",statusName,"<spring:message code='message.lable.userzhanghao'/>");
        	if ( !(infos instanceof Array)){
        		return;
        	}
      	    $.HN.message.confirm('<spring:message code='message.button.confirm' />'+statusName+'<spring:message code='message.HN.alert.yiXiaZhangHao' /><spring:message code='message.yanZheng.wenHao' /><br/>'+infos[1].replace(/\,/g,"<br/>"), '', '').on(function (e) {
                if (e) {
                	$.ajax({
                        url: url,//action地址
                        data: {state:flag,param:infos[0]},//传值
                        type: "post",//执行方式get or post 默认以post方式执行
                        dataType:"json",
                        success: function (result) {//执行成功后 提示
                            if (result.success){
                            	top.$.HN.message.alert("<spring:message code='message.HN.alert.chengGongCaoZuo' />"+infos[0].split(",").length+"<spring:message code='message.HN.alert.tiaoShuJu' /><spring:message code="message.yanZheng.ganTanHao"/>","", "success");
                               search( $("#gridlist").getGridParam("page"));
                            } else {
                        	   top.$.HN.message.alert("<spring:message code='message.HN.alert.fail' /><spring:message code="message.yanZheng.ganTanHao"/>","", "error");
                            } 
                        }
                    });
                }
            });
    	}
    	
    	function search(page) {
    		var data = formatForm("form");
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:data,
    	        page : (page || 1)
    	    }).trigger("reloadGrid"); //重新载入  
    	}
    	function addUser() {
     		$('#addForm')[0].reset();  
     		$("#remark").val("");
    		$('#zxUserAdd').modal({
                keyboard: true
            });
    		
    	}
    	
     	function zxUserEdit(id,username,name,email,phone,remark,bodyHeight,weight,waist,acctExpired) {
     		$('#form2')[0].reset();  
     		$("#remark").val("");
    		$('#zxUserEdit').modal({
                keyboard: true
            });
    		$("#id").val(id);
    		$("#username2").val(username);
    		$("#name2").val(name);
    		$("#email").val(email);
    		$("#phone").val(phone);
    		$("#editweight").val(weight=="null"?"":weight);
    		$("#editbodyHeight").val(bodyHeight=="null"?"":bodyHeight);
    		$("#editwaist").val(waist=="null"?"":waist);
    		$("#editacctExpired").val(acctExpired=="null"?"":acctExpired)
    		$("#remark").val(remark);
    		$("form#form2").data("changed",false);
    	}
    	
     	var userName ="";
    	function changePassword(_id,_username,name) {
    		id = _id || "";
    		$("#password").val("");
    		$("#passwordRepeat").val("");
    		$("#changePasswordDialog").find(".modal-title").html(_username+" - "+name);
    		$('#changePasswordDialog').modal({
                keyboard: true
            });
    		userName=_username;
    	}
    	
    	function submitPassword() {
    		
			var password = $.trim($("#password").val());
			var passwordRepeat = $.trim($("#passwordRepeat").val());
		//	var parn = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{6,12}$/;
		    var parn =new RegExp("^[0-9]*$");
		     if (password == null || password == "") {
		         top.$.HN.message.alert("<spring:message code='message.HN.noPWD'/><spring:message code="message.yanZheng.ganTanHao"/>", "", "warn");
		         return false;
		     } else if (!(parn.test(password))) {
		    	 top.$.HN.message.alert("<spring:message code='message.lable.PWDhint'/>", "", "warn");
		         return false;
		     } else if (password.length != 6) {
		    	 top.$.HN.message.alert("<spring:message code='message.HN.PWDlengthDengYu6'/><spring:message code="message.yanZheng.ganTanHao"/>", "", "warn");
		         return false;
		     }

		     if (passwordRepeat == null || passwordRepeat == "") {
		    	 top.$.HN.message.alert("<spring:message code='message.HN.noConfirmPWD'/><spring:message code="message.yanZheng.ganTanHao"/>", "", "warn");
		         return false;
		     } else if (passwordRepeat != password ) {
		    	 top.$.HN.message.alert("<spring:message code='message.HN.notSamePWD'/>", "", "warn");
		         return false;
		     }
		     
	       	  $.HN.message.confirm("<spring:message code='message.lable.queDingWei'/>"+userName+"<spring:message code='message.lable.zhangHaoChongZhiMiMa'/>", '', '').on(function (e) {
	              if (e) {
	            		$.post("${ctx}/sysUser/changePassword.html", {
	            			"id" : (id || ""),
	            			"password" : password
	            		}, function(result) {
	            			if (result.success) {
	            				$("#closeChangePasswordDialog").click();
	            				top.$.HN.message.alert("<spring:message code='message.HN.alert.success'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "success");
	            			} else {
	            				top.$.HN.message.alert("<spring:message code='message.HN.alert.fail'/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code='message.HN.alert.type'/>", "error");
	            			}
	            		}, "json").error(function(err) {
	            			top.window.document.location = "${ctx}/login.html"; 
	            		});
	    		}
	       	  });
    		
       }
    
        function mainUserPrivilege(id,name){
        	$.HN.dialog.open({
                 id:id,
                 title:name,
                 url:"${ctx}/sysPrivilege/mainUserPrivilege.html?userId="+id,
                 width:"800px",
                 height:"550px",
                 closefunc:function(){
                	 search();
                 }
             });
    }
        $(function () {
            $("#gridlist").jqGrid({
                url: "${ctx}/sysUser/getZxUserList.html",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 250,
                colNames: ['<spring:message code='message.jqGrid.cz'/>',
                           '<spring:message code='message.lable.userzhanghao'/>',
                           '<spring:message code='message.lable.username'/>',
                           '身高',
                           '体重',
                           '腰围',
                           '<spring:message code='message.lable.useremail'/>',
                           '<spring:message code='message.lable.phone'/>',
                           '到期日期',
                           '<spring:message code='message.lable.status'/>',"statusName"],
                colModel: [
                { name: 'operate', width:7, align:"center", sortable: false,title:false,formatter : function(val, opts, rowdata) {
	            	   var email = rowdata.email==null?"":rowdata.email;
	            	   var phone = rowdata.phone==null?"":rowdata.phone;
	            	   var remark = rowdata.remark==null?"":rowdata.remark;
                       	var str = "<ms:btn url='/sysUser/saveZUser.html'><a href='javascript:zxUserEdit(\""+rowdata.id+"\",\""+rowdata.username+"\",\""+rowdata.name+"\",\""+email+"\",\""+phone+"\",\""+remark+"\",\""+rowdata.bodyHeight+"\",\""+rowdata.weight+"\",\""+rowdata.waist+"\",\""+rowdata.acctExpiredStr+"\");' title='编辑' >编辑</a></ms:btn>";
			            str += "<ms:btn url='/sysUser/changePassword.html'><a href='javascript:changePassword(\""+rowdata.id+"\",\""+rowdata.username+"\",\""+rowdata.name+"\");' title='重置密码'>重置密码</a></ms:btn>";
			            //str += "<ms:btn url='/sysPrivilege/mainUserPrivilege.html'><a href='javascript:mainUserPrivilege(\""+rowdata.id+"\",\""+rowdata.name+"\");' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -60px -80px' class='opIcon' title='<spring:message code='message.lable.role' />'></a></ms:btn>";
			            str += "<a href='${pageContext.request.contextPath}/sysUser/toUserRoleManage.html?userId="+rowdata.id+"' title='角色管理'>角色管理</a>";
    	                return str;
                    }},
					{ name: 'username', width: 8, align:"left", sortable: false},
                    { name: 'name', width: 10, align:"left", sortable: false},
                    { name: 'bodyHeight', width: 5, align:"center", sortable: false },
                    { name: 'weight', width: 5, align:"center", sortable: false },
                    { name: 'waist', width: 5, align:"center", sortable: false },
                    { name: 'email', width: 10, align: 'left', sortable: false},
                    { name: 'phone', width: 10, align: 'left', sortable: false},
                    { name: 'acctExpiredStr', width: 10, align: 'center', sortable: false},
                    { name: 'status', width: 5, align: 'center',hidden:true,sortable: false,
                    	formatter : function(val,opts,row){
	                    	if(val==1){
	                    		return "<spring:message code="message.button.start"></spring:message>";
	                    	}else if(val==0){
	                    		return "<span class='red'><spring:message code="message.button.stop"></spring:message></span>";
	                    	}
	                    }
                    },
                    { name: 'statusName', width: 0,hidden:true ,align: 'left', sortable: false}
                ],
                rowNum: 20,
                rowList: [10, 20, 30],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: true, 
                viewrecords: true,
                caption: "用户列表",
                gridComplete:function(){
                    autoRNWidth("gridlist");
                    selectByOneData("gridlist");
                },
                jsonReader: {
                    id: "id"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
    </script>
</body>
</html>












